<template>
  <div>
    <!--引用表格-->
   <BasicTable @register="registerTable" >
     <!--插槽:table标题-->
      <template #tableTitle>
          <a-button type="primary" @click="handleDoRefund" preIcon="ant-design:plus-outlined"> 批量退款</a-button>
          <a-button  type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
      </template>
       <!--操作栏-->
      <template #action="{ record }">
        <TableAction :actions="getTableAction(record)" />
      </template>
      <!--字段回显插槽-->
      <template v-slot:bodyCell="{ column, record, index, text }">
      </template>
    </BasicTable>
  </div>
</template>

<script lang="ts" name="cspurchasemealsorder-csPurchaseMealsOrder" setup>
  import {ref, reactive, computed, unref} from 'vue';
  import {BasicTable, useTable, TableAction} from '/@/components/Table';
  import {useModal} from '/@/components/Modal';
  import { useListPage } from '/@/hooks/system/useListPage'
  import {refundColumns, searchRefundFormSchema, superQuerySchema} from './CsPurchaseMealsOrder.data';
  import {refundList, doMealsRefund, batchDelete, getImportUrl,getExportUrl,refundListExportXls} from './CsPurchaseMealsOrder.api';
  import { downloadFile } from '/@/utils/common/renderUtils';
  import { useUserStore } from '/@/store/modules/user';
  import { useMessage } from "/@/hooks/web/useMessage";
  const { createConfirm } = useMessage();
  const queryParam = reactive<any>({});
  const checkedKeys = ref<Array<string | number>>([]);
  const userStore = useUserStore();

  //注册table数据
  const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
      tableProps:{
           title: '伙食费退费',
           api: refundList,
           columns:refundColumns,
           canResize:false,
           showActionColumn:false,
           formConfig: {
              //labelWidth: 120,
              schemas: searchRefundFormSchema,
              autoSubmitOnEnter:true,
              showAdvancedButton:true,
              fieldMapToNumber: [
              ]
             
            },
           actionColumn: {
               width: 120,
               fixed:'right'
            },
            beforeFetch: (params) => {
              return Object.assign(params, queryParam);
            },
      },
       exportConfig: {
            name:"伙食费退费",
            url: refundListExportXls,
            params: queryParam,
          },
          importConfig: {
            url: getImportUrl,
            success: handleSuccess
          },
  })

  const [registerTable, {reload},{selectedRowKeys }] = tableContext

  // 高级查询配置
  const superQueryConfig = reactive(superQuerySchema);

  /**
   * 高级查询事件
   */
  function handleSuperQuery(params) {
    Object.keys(params).map((k) => {
      queryParam[k] = params[k];
    });
    reload();
  }
  

   
   /**
    * 执行退款操作
    */
    function handleDoRefund() {
      createConfirm({
      iconType: 'warning',
      title: '退费提醒',
      content: '您确认要执行该操作？',
       okText: '确认',
       cancelText: '取消',
       onOk: () => {
         return doMealsRefund({}, handleSuccess);
        }
     });
      
   }
  
   /**
    * 成功回调
    */
  function handleSuccess() {
      (selectedRowKeys.value = []) && reload();
   }
   /**
      * 操作栏
      */
  function getTableAction(record){
       return [
         
       ]
   }
   


</script>

<style scoped>

</style>